package appcomp.entities;

import core.CodeGenerator;

public class CompositePort extends Port {

	private Port original; 
	
	public enum Visibility {INTERNAL, EXTERNAL, BOTH};
	
	private Visibility portVis;
	
	public CompositePort(String name, Visibility vis, Connector conn, Port orig) {
		this.original = orig;
		this.setName(name);
		portVis = vis;
		this.direction = orig.getDirection();
		this.handler = orig.handler;
		this.conn = conn;
		this.type = orig.type;
	}

	/**
	 * @return the original
	 */
	public Port getOriginal() {
		return original;
	}

	/**
	 * @param original the original to set
	 */
	public void setOriginal(Port original) {
		this.original = original;
	}

	/**
	 * @return the portVis
	 */
	public Visibility getPortVis() {
		return portVis;
	}

	/**
	 * @param portVis the portVis to set
	 */
	public void setPortVis(Visibility portVis) {
		this.portVis = portVis;
	}
	
	public String printFullName() {
		return this.getName() + ":" + this.getDirection() + ":" + this.portVis;
	}

	/* (non-Javadoc)
	 * @see appcomp.entities.Port#generateCode(core.CodeGenerator)
	 */
	@Override
	public void generateCode(CodeGenerator cg) {
		if(this.getDirection() == Port.Direction.IN) {
			this.getFile().println("\tvoid " + this.handler + "(" + this.type.getCoreType() + " * data, unsigned long dataSize);");
			this.getFile().println("\t" + this.type.getCoreType() + " * gen" + this.getName() + "Request();");
		}

	}
	
}
